#include "serialctlthread.h"

SerialCtlThread::SerialCtlThread(QObject *parent) :
    QThread(parent)
{
    //注册
    qRegisterMetaType<LcdSettingStruct>("LcdSettingStruct");
    qRegisterMetaType< QList<LCDSTATUS> >("QList<LCDSTATUS>");
    qRegisterMetaType< QList<PanelInfoStruct> >("QList<PanelInfoStruct>");
    qRegisterMetaType< QList<quint16> >("QList<quint16>");

}

SerialCtlThread::~SerialCtlThread()
{
    delete m_serialCtrl;
}

void SerialCtlThread::run()
{
    m_serialCtrl = new SerialCtl();

    connect(this, SIGNAL(receGetLcdStatus()),                              m_serialCtrl, SLOT(checkLcdStatus()));
    connect(this, SIGNAL(receLcdBackLightCtl(qint8,QList<quint16>)),       m_serialCtrl, SLOT(lcdBackLightCtl(qint8,QList<quint16>)));

    connect(this, SIGNAL(receQueryVideoStatus(qint8)),                     m_serialCtrl, SLOT(queryVideoStatus(qint8)));
    connect(this, SIGNAL(receSlcdCollectState(QList<PanelInfoStruct>)),    m_serialCtrl, SLOT(setSlcdCollectSate(QList<PanelInfoStruct>)));

    connect(this, SIGNAL(receChangeBriLv(LcdSettingStruct)),               m_serialCtrl, SLOT(receChangeBriLv(LcdSettingStruct)));
    connect(this, SIGNAL(receChangeLcdBright(qint16,QList<quint16>)),      m_serialCtrl, SLOT(changeLcdBright(qint16,QList<quint16>)));
    connect(this, SIGNAL(getLcdSetting()),                                 m_serialCtrl, SLOT(checkLcdSetting()));
    connect(this, SIGNAL(updateConfig()),                                  m_serialCtrl, SLOT(updateConfig()));
    connect(this, SIGNAL(tisSelfTestSignal()),                             m_serialCtrl, SLOT(TisSelfTest()));

//    connect(m_serialCtrl, SIGNAL(sendVideoStatus(QList<LCDSTATUS>,bool)),  this, SIGNAL(sendVideoStatus(QList<LCDSTATUS>,bool)));
    connect(m_serialCtrl, SIGNAL(sendSensorData(qint16)),                  this, SIGNAL(sendSensorData(qint16)));
    connect(m_serialCtrl, SIGNAL(sendLcdSetting(LcdSettingStruct)),        this, SIGNAL(sendLcdSetting(LcdSettingStruct)));
    connect(m_serialCtrl, SIGNAL(sendSetLcdSettingStatus(qint8)),          this, SIGNAL(sendSetLcdSettingStatus(qint8)));
    connect(m_serialCtrl, SIGNAL(sendSetLcdTraValueStatus(qint8)),         this, SIGNAL(sendSetLcdTraValueStatus(qint8)));

    connect(m_serialCtrl, SIGNAL(sendBackLightStatus(qint8)),              this, SIGNAL(sendBackLightStatus(qint8)));
    connect(m_serialCtrl, SIGNAL(sendVideoStatus(QList<LCDSTATUS>,bool)),  this, SIGNAL(sendVideoStatus(QList<LCDSTATUS>,bool)));


    connect(m_serialCtrl, SIGNAL(lcdAnswerStatus(QList<LCDSTATUS>)),       this, SIGNAL(lcdAnswerStatus(QList<LCDSTATUS>)));
    connect(m_serialCtrl, SIGNAL(sendLcdSetting(LcdSettingStruct)),        this, SIGNAL(sendLcdSetting(LcdSettingStruct)));

    exec();
}

void SerialCtlThread::tisSelfTest()
{
    emit tisSelfTestSignal();
}
